package com.bilgeadam.swing.program;

import java.awt.BorderLayout;
import java.awt.GridBagLayout;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author Bora SAYINER
 * @since Dec 13, 2014 1:03:06 PM
 * @version 1.0
 */
public class GridLayoutSample {

	public static void main(String[] args) {
		JFrame frmMain = new JFrame();
		frmMain.setTitle("Grid Layout");
		frmMain.setSize(800, 600);
		frmMain.setLocationRelativeTo(null);
		frmMain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		// frmMain.setExtendedState(JFrame.MAXIMIZED_BOTH);
		// frmMain.setUndecorated(true);
		{
			JPanel pnlCenter = new JPanel();
			GridLayout gridLayout = new GridLayout();
			gridLayout.setRows(2);
			pnlCenter.setLayout(gridLayout);
			{
				for (int i = 0; i < 16; i++) {
					String text = String.format("%s. Button", i + 1);
					JButton button = new JButton(text);
					pnlCenter.add(button);
				}
			}
			frmMain.add(pnlCenter, BorderLayout.CENTER);
		}
		frmMain.setVisible(true);
	}
}
